//
//  SetContactView.swift
//  imprint
//
//  Created by 小柠檬🍋 on 2024/12/26.
//

import SwiftUI

struct SetContactView: View {
    @EnvironmentObject var pathManager : PathManager
    @State private var showContactDialog = false
    var body: some View {
            HStack{
                VStack(alignment: .leading, spacing: 10) {
                    Text("联系")
                        .foregroundColor(.bgItemContent)
                        .fontWeight(.bold)
                        .font(.system(size: 14))
                    HStack {
                         Text("公告")
                            .font(.system(size: 14))
                            .foregroundColor(.bgItemContent)
                         Spacer()
                         Image(systemName: "arrow.right.circle.fill")
                             .resizable()
                             .scaledToFit()
                             .foregroundColor(.gray.opacity(0.5))
                             .frame(width: 15, height: 15)
                             .clipped()
                    }.padding(.top,5)
                        .padding(.bottom,5)
                        .contentShape(Rectangle())
                        .onTapGesture {
                            pathManager.jump(type: JumpType.NOTIFY_VIEW)
                        }
                    if !isExamine() {
                        HStack {
                            Text("联系我们")
                                .font(.system(size: 14))
                                .foregroundColor(.bgItemContent)
                            Spacer()
                            Image(systemName: "arrow.right.circle.fill")
                                .resizable()
                                .scaledToFit()
                                .foregroundColor(.gray.opacity(0.5))
                                .frame(width: 15, height: 15)
                                .clipped()
                        }.padding(.top,5).padding(.bottom,5)
                            .contentShape(Rectangle())// 将整个矩形区域（包括padding）都设置为可点击区域
                            .onTapGesture {
                                showContactDialog.toggle()
                            }
                            .confirmationDialog("联系我们", isPresented: $showContactDialog){
                                Button("微信"){
                                    contactWx()
                                }
                                Button("QQ"){
                                    contactQQ()
                                }
                                Button("QQ群"){
                                    contactQQGroup(groupUin: configManager.getConfig().qqGroup?.qqGroup ?? "", key: configManager.getConfig().qqGroup?.qqGroupKeyIos ?? "")
                                }
                                Button("取消", role: .cancel){}
                            } message: {
                                Text("请选择联系方式")
                            }
                    }
                    HStack {
                         Text("意见反馈")
                            .font(.system(size: 14))
                            .foregroundColor(.bgItemContent)
                         Spacer()
                        Image(systemName: "arrow.right.circle.fill")
                            .resizable()
                            .scaledToFit()
                            .foregroundColor(.gray.opacity(0.5))
                            .frame(width: 15, height: 15)
                            .clipped()
                    }.padding(.top,5)
                        .padding(.bottom,5)
                        .contentShape(Rectangle())
                            .onTapGesture {
                                pathManager.jump(type: JumpType.FEEDBACK)
                            }
//                    HStack {
//                         Text("好评鼓励")
//                            .font(.system(size: 14))
//                            .foregroundColor(.bgItemContent)
//                         Spacer()
//                        Image(systemName: "arrow.right.circle.fill")
//                            .resizable()
//                            .scaledToFit()
//                            .foregroundColor(.gray.opacity(0.5))
//                            .frame(width: 15, height: 15)
//                            .clipped()
//                    }.padding(.top,5).padding(.bottom,5)
//                    HStack {
//                         Text("分享好友")
//                            .font(.system(size: 14))
//                            .foregroundColor(.bgItemContent)
//                         Spacer()
//                        Image(systemName: "arrow.right.circle.fill")
//                            .resizable()
//                            .scaledToFit()
//                            .foregroundColor(.gray.opacity(0.5))
//                            .frame(width: 15, height: 15)
//                            .clipped()
//                    }.padding(.top,5).padding(.bottom,5)
                }
                Spacer()
            }.frame(maxWidth: .infinity).padding().background(.bgItem).clipShape(RoundedRectangle(cornerRadius: 15))
        }
}

//#Preview {
//    SetContactView()
//}

struct SetContact_Previews: PreviewProvider {
    static var previews: some View {
        //使用预览共享配置
        configurePreviewEnvironment(for: SetContactView())
    }
}
